/*
 * Copyright (c) 2023 Cshoo Org. All Rights Reserved.
 */

package org.cshoo.tattoo.datacenter.domain.repository;

import org.cshoo.tattoo.datacenter.domain.po.Config;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

/**
 * @author 杨翼
 * @since 1.0
 */
public interface IConfigRepository extends CrudRepository<Config, Long> {

    /**
     * 根据编号查询config
     *
     * @param code 编号
     * @return config
     */
    Config findByCode(String code);

    /**
     * 分页查询config
     *
     * @param keyword 查询关键字
     * @param pageable             分页对象
     * @return config分页列表
     */
    @Query("SELECT config FROM Config config WHERE config.code like %:#{#keyword}% OR config.name LIKE %:#{#keyword}%")
    Page<Config> findConfig(String keyword, Pageable pageable);


}
